<?php
App::import('Controller', 'Posts');
App::import('Model', 'FutureTweet');
class PostsControllerTest extends ControllerTestCase {
public function startTest(){
    $this->Posts = new PostsController();
    $this->Posts->constructClasses();
	$this->FutureTweet = new FutureTweet();
}
public function testhelper() {
	$text = rand().''.rand().''.rand();
	$data = array("Text"=>$text);
    $result = $this->testAction('/Posts/helper/null/null', array('data' => $data));
	$this->assertTrue($result);
		$data = array("Text"=>"         ");
    $result = $this->testAction('/Posts/helper/null/null', array('data' => $data));
				$this->assertFalse($result);
		$data = array("Text"=>"");
    $result = $this->testAction('/Posts/helper/null/null', array('data' => $data));
				$this->assertFalse($result);
		$data = array("Text"=>"ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
		ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
		sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss");
    $result = $this->testAction('/Posts/helper/null/null', array('data' => $data));
				$this->assertFalse($result);
				$data = array("Text"=>"ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
		https://www.google.com.eg/search?q=cakephp+how+to+make+a+form+submitted+to+another+action&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
		");
    $result = $this->testAction('/Posts/helper/null/null', array('data' => $data));
				$this->assertTrue($result);
    }

/*
     * Description of the function:
     * This function tests if any other user except the admin can delete a certain tweet
     *
     * @author "Omar Safwany"
     */

    public function testdeleteTweets() {
        $this->PostsController->Auth->staticExpects($this->any())
                ->method('User', 'User')
                ->with($this->logicalOr(
                                $this->equalTo('userID'), $this->equalTo('accID'), $this->equalTo('admin')
                        ))
                ->will($this->returnCallback(array($this, 'viewAllSimpleVarsCallback')));
        $result = $this->testAction('/posts/deleteTweets/10', array('method' => 'get', 'return' => 'view'));
        $this->assertTrue($result == null);
    }

    /*
     * Description of the function:
     * This function tests if any other user except the admin can delete all of the tweets of a certain user.
     *
     * @author "Omar Safwany"
     */

    public function testdeleteAll() {
        $this->PostsController->Auth->staticExpects($this->any())
                ->method('User', 'User')
                ->with($this->logicalOr(
                                $this->equalTo('userID'), $this->equalTo('accID'), $this->equalTo('admin')
                        ))
                ->will($this->returnCallback(array($this, 'viewAllSimpleVarsCallback')));
        $result = $this->testAction('/posts/deleteAll/1', array('method' => 'get', 'return' => 'view'));
        $this->assertTrue($result == null);
    }	
	public function testSearch(){
	$result1 = $this->testAction('/Posts/search/', array('data' => '??'));
	$expected1 = null;
	$this->assertEquals($expected1, $result1);

	
	}
	}